<?php

namespace app\common\model;

use think\db;
use think\Model;

class Smssends extends Model {

    /**
     *  获取所有列表
     * @return type
     */
    public function getAll($where = null) {
        return $this->where($where)->order('id', 'asc')->select()->toArray();
    }

    public function getById($val,$field='id') {
        return (Object) $this->where($field, $val)->find()->toArray();
    }

    /**
     * 添加
     */
    public function add($sme) {
        $result = $this->save($sme);
        if (false !== $result) {
            return [1, "发送成功！", $this->id];
        } else {
            return [0, $this->getError()];
        }
    }

    /**
     * 修改
     */
    public function modify($opt, $id) {
        $result = $this->update($opt, 'id=' . $id);
        if (false !== $result) {
            return [1, "更新成功"];
        } else {
            return [0, $this->getError()];
        }
    }

}
